<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;

class UtilsController extends Controller
{
    public function longUrl2ShortUrl(Request $request)
    {
        $url_long = $request->input('url_long');
        $url = "http://api.t.sina.com.cn/short_url/shorten.json?source=3271760578&url_long=" . urlencode($url_long);
        echo get($url);
    }

    public function getQRCode(Request $request)
    {
        $url = $request->input('url');
//        echo $url;exit;
        if ($url) {
            $img = "http://bshare.optimix.asia/barCode?site=weixin&url=" . urlencode($url);
//            return file_get_contents($img);

            header("location:$img");
            return;
//            return $this->response->array([
//                'url' => "http://bshare.optimix.asia/barCode?site=weixin&url=" . urlencode($url)
//            ]);
        } else {
            return "";
        }
    }
}
